<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("modelConfigPath", "billing");
%>
<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>
<style >
	#outStockInfoCopy{display:none}
	td input{height:21px; width:98%;border:none;}
	td{height:21px;padding: 2px 2px !important;text-align:center }
	#area{
		height:420px;
		overflow-y:auto; 
		overflow-x:hidden; 
	}
</style>
	
<t:panel cssClass="panel-flat form-detailed" customBody="true" customHead="true">
	<div class="detailed-navbar-content panel-body">
		<t:form modelAttribute="billing" action="/billing/billing/sendOutGoodsSave" method="post" cssClass="form-horizontal">
			<div class="hide">
				 <t:hidden path="billingId"/>
 				 <t:hidden path="deleteMark"/>	
 				 <t:hidden path="createUserName"/>
		 		 <t:hidden path="createUserId"/>
		 		 <t:hidden path="createDate"/>
		 		 <t:hidden path="shopId"/>
		 		 <t:hidden path="confirm"/>
			</div>
            <t:formgroup>
            	<t:label path="billingNo" cssClass="col-sm-1 col-xs-1" />
		        <t:input readonly="true" path="billingNo" colClass="col-sm-2 col-xs-2" />
                <t:label path="customerId" cssClass="col-sm-1 col-xs-1" />
                <t:select2 readonly="true" path="customerId" placeholder="请填写客户" allowClear="true" colClass="col-sm-2 col-xs-2"></t:select2>

            	<t:label path="deliveryDate" cssClass="col-sm-1 col-xs-1" />
                <t:date readonly="true"  path="deliveryDate" colClass="col-sm-2 col-xs-2"></t:date>
                <t:label path="businessId" cssClass="col-sm-1 col-xs-1" />
                <t:select2 readonly="true" path="businessId" placeholder="业务员" allowClear="true" colClass="col-sm-2 col-xs-2"></t:select2>
            </t:formgroup>
            <div id="area">
            <table  class="cntable table table-bordered dataTable table-billing">
	            <thead>
	            	<tr class="success">
		            	<th style="width:50px"></th>
		            	<th style="width:200px">商品编码</th>
		            	<th style="width:200px">商品名称</th>
		            	<th style="width:150px">规格</th>
		            	<th style="width:100px">单位</th>
		            	<th style="width:100px">售价</th>
		            	<th style="width:100px">欠货</th>
		            	<th>发货数</th>
	            	</tr>
	            </thead>
	            
	            <tbody id="outStockInfo">
	            	<c:set var="sequence"  value="0"/>
					<c:forEach var="outStockShow" items="${billing.outStock.outStockShows}">
						<c:forEach var="outStockCollocation" items="${outStockShow.outStockCollocations}" >
							<tr id="outStockCollocation_${sequence}">
								<td style="display:none"><input id="showIdYuan_${sequence}" name="showIdYuan" type="text" value="${outStockShow.showId}"/></td>
								<td style="display:none"><input id="outStockCollocationIdYuan_${sequence}" name="outStockCollocationIdYuan" type="text" value="${outStockCollocation.outStockCollocationId}"/></td>
								<td style="display:none"><input id="collocationId_${sequence}" name="collocationId" type="text" value="${outStockCollocation.collocationId}"/></td>
								<td style="display:none"><input id="cargoId_${sequence}" name="cargoId" type="text" value="${outStockShow.cargoId}"/></td>
								<td style="display:none"><input style="ime-mode:disabled" id="subtotal_${sequence}" name="subtotal" type="text" value="${outStockCollocation.realPrice*outStockCollocation.collocationNum}"/></td>
								<td>${sequence+1}</td>						
				            	<td><input style="ime-mode:disabled" disabled="disabled" id="cargoNo_${sequence}" name="cargoNo" type="text" value="${outStockShow.cargo.cargoNo}"></input></td>
				            	<td><input style="ime-mode:disabled" disabled="disabled" id="cargoName_${sequence}" name="cargoName" type="text" value="${outStockShow.cargo.cargoName}"/></td>
				            	<c:if test="${outStockCollocation.collocation.propertyNameTwo==null }">
				            		<td><input style="ime-mode:disabled" disabled="disabled" id="propertyName_${sequence}" name="propertyName" type="text" value="${outStockCollocation.collocation.propertyNameOne}"/></td>
				            	</c:if>
				            	<c:if test="${outStockCollocation.collocation.propertyNameTwo!=null }">
				            		<td><input style="ime-mode:disabled" disabled="disabled" id="propertyName_${sequence}" name="propertyName" type="text" value="${outStockCollocation.collocation.propertyNameOne}/${outStockCollocation.collocation.propertyNameTwo}"/></td>
				            	</c:if>
				            	<td ><input style="ime-mode:disabled" readonly="true" id="unit_${sequence}" name="unitForTransform" type="text" value="${outStockShow.cargo.unit}"/></td>
								<td><input style="ime-mode:disabled" readonly="true" id="realPrice_${sequence}" name="realPrice" type="text" value="${outStockCollocation.realPrice}"/></td>
								<td><input style="ime-mode:disabled" readonly="true" id="collocationDebt_${sequence}"  name="collocationDebt" type="text" value="${outStockCollocation.collocationDebt}"/></td>
								<td><input style="ime-mode:disabled" onkeyup="return ValidateNumber(this,value)" id="collocationNum_${sequence}" name="collocationNum" type="text" value="${outStockCollocation.collocationDebt}"/></td>
								
							</tr>
							<c:set var="sequence"  value="${sequence +1}"/>
						</c:forEach>
					</c:forEach>
				</tbody>
            </table>
			</div>
		</t:form>
	</div>
	<t:panelFoot headingBtnCssClass="heading-btn pull-right-important">
		<t:button icon="icon-floppy-disk" onclick="saveData()" laddaType="progress" cssClass="btn-info" csize="sm">发货</t:button>
	</t:panelFoot>
</t:panel>

<script type="text/javascript">

$(function(){


})

function saveData(lBtn){
	var isSave=false;
	$("input[name='collocationId']").each(function(){
		if($(this).val()!=null && $(this).val() != ""){
			isSave=true;
		}
						
	});
	var returnCargoNum=false;
	$("input[name='collocationNum']").each(function(){
		if($(this).val()!= 0){
			returnCargoNum=true;
		}			
	});
	if(!isSave){
		$.showTips("请选择开单货品！",1000,"warning");
		return;
	}
	if(!returnCargoNum){
		$.showTips("请填写数量！",1000,"warning");
		return;
	}

	if (!$("form:first").valid()){
		return;
	}
	lBtn.start();
	$("form:first").submit();
}	



function ValidateNumber(e, pnumber){
	if (!/^\d+[.]?\d*$/.test(pnumber))
	{
	e.value = /^\d+[.]?\d*/.exec(e.value);
	}else{
		
 	}
	return false;
}
</script>
<%@ include file="/WEB-INF/views/shared/base/scripts/jqueryui.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formtags.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formbuttons.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formpickers.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/dialog.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/contentFooter.jsp"%>